////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//         This file is distributed under the BSD 2-Clause open source license. See Licenses/License.txt for details.         //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __WN_STRUCT_H__
#define __WN_STRUCT_H__
#include "WNScripting/inc/WNNode.h"
#include "WNScripting/inc/WNScriptingErrors.h"
#include "WNScripting/inc/WNScriptLinkedList.h"
#include "WNScripting/inc/WNTypeElement.h"

#include "WNLogging/inc/WNLog.h"
#include <vector>
namespace WNScripting {    
    class WNDeclaration;
    class WNCodeModule;
    struct WNFunctionDefinition;
    class WNStruct : public WNNode{
    public:
        WNStruct(const char* _name);
        virtual ~WNStruct();

        void AddStructElem(WNDeclaration* _decl);
        eWNTypeError ExportNewTypes(WNCodeModule& _module, std::vector<WNScriptType>& _types, std::vector<WNFunctionDefinition*>& _functionDefs, WNLogging::WNLog& _compilationLog);
        eWNTypeError FinalizeNewTypes(WNCodeModule& _module, WNLogging::WNLog& _compilationLog);
        eWNTypeError FinalizeStruct(WNCodeModule& _module, WNScriptType scriptType, WNLogging::WNLog& _compilationLog);
        eWNTypeError GenerateHeader(WNCodeModule& _module, WNLogging::WNLog& _compilationLog);
        eWNTypeError GenerateCode(WNCodeModule& _module, WNLogging::WNLog& _compilationLog);

    private:

        eWNTypeError GenerateConstructor(WNCodeModule& _module, WNLogging::WNLog& _compilationLog);

        eWNTypeError GenerateDestructor(WNCodeModule& _module, WNLogging::WNLog& _compilationLog);
        char* mName;
        WNScriptLinkedList<WNDeclaration> mStructMembers;
    };
}
#endif//__WN_STRUCT_H__
